<%--
  Created by IntelliJ IDEA.
  User: lizeze
  Date: 2018/7/6
  Time: 上午2:04
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html;charset=UTF-8" %>
<%@ include file="/static/include/taglib.jsp" %>
<html>
<head>
    <title>Title</title>
    <link href="${ctxStatic}/layui/css/layui.css" rel="stylesheet"/>
    <link href="${ctxStatic}/css/kpiui.css" rel="stylesheet"/>
    <script src="${ctxStatic}/js/jquery-1.8.3.min.js?v=2.0" type="text/javascript"></script>
    <script src="${ctxStatic}/layui/layui.all.js" type="text/javascript"></script>
    <script src="${ctxStatic}/js/office/Blob.js" type="text/javascript"></script>
    <script src="${ctxStatic}/js/office/Blob.js" type="text/javascript"></script>
    <script src="${ctxStatic}/js/office/FileSaver.js" type="text/javascript"></script>
    <script src="${ctxStatic}/js/office/tableExport.js" type="text/javascript"></script>

    <style>


    </style>
</head>
<body>
<%--<div id="export">--%>
<%--<a data-type="doc" href="javascript:;">导出word</a>--%>
<%--</div>--%>

<div class="indexcontent" style="height: 450px;overflow: scroll">


    <div class="selftable" id="selftable">

        <table id="tableData" cellspacing="0" cellpadding="0" border="0" class="layui-table" style="margin:0;">

            <thead>

            <tr style="text-align: center">
                <th colspan="${titleh.size()+4}">考评期间:${date}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 考评单位:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    &nbsp;&nbsp;&nbsp;&nbsp; 考评组别:
                </th>

            </tr>
            <tr>
                <th rowspan="2">序号</th>
                <th rowspan="2">被评单位</th>
                <th colspan="${titleh.size()}" style="text-align: center">单项得分</th>
                <th style="width: 100px" rowspan="2">总计</th>
                <th style="width: 100px" rowspan="2">排名</th>


            </tr>
            <tr>
                <c:forEach var="itemth" items="${titleh}" varStatus="idxStatus">
                    <th style="width: 85px">${itemth.uassingredients}<br>(${itemth.score}分)</th>
                </c:forEach>
            </tr>
            </thead>
            <tbody>
            <c:forEach var="item" items="${databody}" varStatus="idxStatus">
                <tr>
                    <td>${idxStatus.index+1}</td>
                    <td>${item['orgname']}</td>
                    <c:forEach var="itembody" items="${titleh}">
                        <td>${item[itembody.assindexidcolum]}</td>
                    </c:forEach>
                    <td style="width: 100px" class="   orgSum orgSum_${item['orgid']}">${item['sumscore']}</td>
                    <td style="width: 100px" class="orgOrder_${item['orgid']}"></td>
                </tr>
            </c:forEach>

            </tbody>
        </table>
    </div>
</div>
<div id="miaoshu" style="border: 1px solid white;
    color: white;">${remark}
</div>

</body>

<script>
    $(function () {

        //
        // var $exportLink = document.getElementById('export');
        //
        // $exportLink.addEventListener('click', function(e){
        //
        //     e.preventDefault();
        //
        //     if(e.target.nodeName === "A"){
        //
        //         tableExport('tableData', '测试测试', e.target.getAttribute('data-type'));
        //
        //     }
        //
        //
        //
        // }, false);


        var orgScores = [];

        function sequence(a, b) {
            return b - a;
        }

        Array.prototype.unique3 = function () {
            var res = [];
            var json = {};
            for (var i = 0; i < this.length; i++) {
                if (!json[this[i]]) {
                    res.push(this[i]);
                    json[this[i]] = 1;
                }
            }
            return res;
        }

        var orgSums = $('.orgSum');
        for (var i = 0; i < orgSums.length; i++) {

            orgScores.push($(orgSums[i]).text())

        }
        var index = 0;
        orgScores = orgScores.unique3().sort(sequence);
        for (var i = 0; i < orgScores.length; i++) {
            index++;
            for (var j = 0; j < orgSums.length; j++) {
                if (orgScores[i] == $(orgSums[j]).text()) {


                    $($($($(orgSums[j]))[0]).next()[0]).text(index)
                }


            }


        }

    })


</script>
</html>
